Skip to content

fix(http2): send "100 Continue" on the server - #4217

Open
grosskur wants to merge 2 commits into
hyperium:masterfrom
grosskur:grosskur/h2-expect-continue
Open

grosskur wants to merge 2 commits into
hyperium:masterfrom
grosskur:grosskur/h2-expect-continue

Conversation

@grosskur

@grosskur grosskur commented Oct 1, 2026 •

Copy link
Copy Markdown

Per RFC 9110, 10.1.1: If a request has Expect: 100-continue, the server should either send 100 Continue to say it is ready for the request body, or send a final status such as 417 Expectation Failed.

The HTTP/1 server handles this correctly: it sends 100 Continue the first time the service polls the request body. However, the HTTP/2 server ignores Expect, so a client that waits for 100 Continue before sending its body stalls until its own timeout.

Fix this by making the HTTP/2 server send 100 Continue after the service first polls the request body. Note that if the body has already started arriving by then, this means the client did not wait, so we skip the 100 Continue (which RFC 9110 allows). As with HTTP/1, nothing is sent if the request has no body, or if the service responds before polling the body, since an interim response cannot follow the final response.

Fixes #2743
Refs: #2119, #3137

Per RFC 9110, 10.1.1: If a request has `Expect: 100-continue`, the
server should either send `100 Continue` to say it is ready for the
request body, or send a final status such as `417 Expectation Failed`.

The HTTP/1 server handles this correctly: it sends `100 Continue` the
first time the service polls the request body. However, the HTTP/2
server ignores `Expect`, so a client that waits for `100 Continue`
before sending its body stalls until its own timeout.

Fix this by making the HTTP/2 server send `100 Continue` after the
service first polls the request body. Note that if the body has
already started arriving by then, this means the client did not wait,
so we skip the `100 Continue` (which RFC 9110 allows). As with HTTP/1,
nothing is sent if the request has no body, or if the service responds
before polling the body, since an interim response cannot follow the
final response.

Fixes hyperium#2743
Refs: hyperium#2119, hyperium#3137
@houseme

houseme commented Nov 16, 2026

Copy link
Copy Markdown

We urgently need this feature to be merged and a new version released. Thank you all!

@BTF-Kabir-2020 BTF-Kabir-2020 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through this against the old #2743 discussion and the HTTP/1 path (#2119 and #3137). Wiring the h2 side to the same "wait until the service polls the body" rule looks like the right approach. RFC 9113 §8.8.5 explicitly shows 100 Continue as an HTTP/2 HEADERS frame with :status = 100, and the pinned h2 (0.4.14) already has SendResponse::send_informational, so no dependency bump is needed.

Two things I'd like to clarify before this lands:

  1. src/body/incoming.rs — the res.is_pending() condition.

    A Ready(Ok(Some(_))) from the first poll_frame suppresses the 100 even if that frame was only the first DATA frame of a larger body. RFC 9110 §10.1.1 explicitly allows omitting 100 Continue if the server has already received "some or all" of the content, so I agree with the current behaviour. However, the comment currently says only "the body hasn't already arrived", which could be read as referring to the whole body. A short reference to that RFC clause would make the intent clearer.

  2. tests/server.rs — h2_expect_continue_but_body_already_sent_is_ignored.

    This test looks scheduler-dependent. send_data() queues the DATA frame on the client stream, but doesn't guarantee the server has it before the service's first body poll. If the server's first body poll happens before the DATA frame has been received, the oneshot fires and the server quite correctly sends a 100, so h2_assert_no_informational fails even though the implementation is fine.

    Could we make the DATA arrival deterministic rather than relying on task ordering? I'd avoid fixing this by only moving the assertion later: poll_informational returns Ready(None) once no more informational responses are expected, so polling after the final response is queued could hide a 100 that really was sent (https://docs.rs/h2/0.4.14/h2/client/struct.ResponseFuture.html#method.poll_informational).

Other than that, the implementation looks consistent with the existing HTTP/1 behaviour and the feature gates line up. I haven't run the suite locally — this is from reading the diff, the protocol text, and the pinned h2 API.

Happy to take another look once the test ordering is settled.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expect: 100-continue not implemented for HTTP/2

4 participants